package com.drug.mingkang.service.impl;

import com.drug.mingkang.model.HqOutbound;
import com.drug.mingkang.mapper.HqOutboundMapper;
import com.drug.mingkang.service.HqOutboundService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 入库明细(HqOutbound)表服务实现类
 *
 * @author wenchangjian
 * @since 2020-08-11 12:00:13
 */
@Service("hqOutboundService")
public class HqOutboundServiceImpl implements HqOutboundService {
    @Resource
    private HqOutboundMapper hqOutboundMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param outId 主键
     * @return 实例对象
     */
    @Override
    public HqOutbound queryById(String outId) {
        return this.hqOutboundMapper.queryById(outId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<HqOutbound> queryAllByLimit(int offset, int limit) {
        return this.hqOutboundMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param hqOutbound 实例对象
     * @return 实例对象
     */
    @Override
    public HqOutbound insert(HqOutbound hqOutbound) {
        this.hqOutboundMapper.insert(hqOutbound);
        return hqOutbound;
    }

    /**
     * 修改数据
     *
     * @param hqOutbound 实例对象
     * @return 实例对象
     */
    @Override
    public HqOutbound update(HqOutbound hqOutbound) {
        this.hqOutboundMapper.update(hqOutbound);
        return this.queryById(hqOutbound.getOutId());
    }

    /**
     * 通过主键删除数据
     *
     * @param outId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String outId) {
        return this.hqOutboundMapper.deleteById(outId) > 0;
    }
}